<?php
/**
 * File: User.php
 * User: Mr.Yang
 * Date: 2025/3/24 0024
 * Time: 15:22
 * Note:
 */

namespace app\home\validate;


use think\Validate;

class User extends Validate
{
    protected $rule = [
        'avatar' => 'require',
        'username' => 'require|min:5|alpha',
        'password' => 'require|min:5',
        'rpassword' => 'require|confirm:password',
        'truename' => 'require',
        'captcha' => 'require',
        'mobile' => 'require|mobile',
    ];

    protected $message = [
        'avatar.require' => '头像不能为空',
        'username.require' => '账号不能为空',
        'username.min' => '账号不能少于5位',
        'username.alpha' => '账号只能是字母',
        'password.require' => '密码不能为空',
        'password.min' => '密码不能少于5位',
        'rpassword.require' => '密码不能为空',
        'rpassword.confirm' => '两次密码不一致',
        'captcha.require' => '验证码不能为空',
        'truename.require' => '姓名不能为空',
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号格式错误',
    ];

    protected $scene = [
        'login' => ['username', 'password', 'captcha'],
        'register' => ['username', 'password', 'rpassword', 'truename','mobile'],
        'edit' => ['avatar', 'username', 'truename', 'mobile']
    ];
}